#include <iostream>
#include <ranges>

using std::cin, std::cout, std::string;
using ull = unsigned long long;
constexpr auto range = std::ranges::views::iota;

constexpr size_t MAX_N{(size_t)3e5 + 5}, MOD{998244353};
string s;
ull stk[MAX_N], left_num[MAX_N], dp[MAX_N], ans;
size_t stk_size;

int main() {
  cin >> s;
  for (const size_t i : range((size_t)0, s.size())) {
    if (s[i] == '(') {
      stk[stk_size++] = i + 1;
    } else if (stk_size > 0) {
      left_num[i] = stk[--stk_size];
      dp[i] = (dp[left_num[i] - 2] + left_num[i]) % MOD;
      ans = (ans + dp[i] * (s.size() - i)) % MOD;
    }
  }
  cout << ans << '\n';
}